#!/bin/bash
sath89/oracle-xe-11g
docker run -d \
    --privileged=true \
    -v /etc/localtime:/etc/localtime:ro \
    --name gitlab \
    -p 30443:443 -p 30080:80 -p 30022:22 \
    -v /opt/module/gitlab/config:/etc/gitlab \
    -v /opt/module/gitlab/logs:/var/log/gitlab \
    -v /opt/module/gitlab/data:/var/opt/gitlab \
    gitlab/gitlab-ce
# 查看gitlab版本号
docker exec gitlab cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
# 邮箱配置，编辑配置文件
# vi /etc/gitlab/gitlab.rb
# gitlab_rails['gitlab_email_enabled'] = true
# gitlab_rails['gitlab_email_from'] = 'gitlab@maxwoods.net'
# gitlab_rails['gitlab_email_display_name'] = 'gitlab'
# gitlab_rails['gitlab_email_reply_to'] = 'gitlab@maxwoods.net'
# gitlab_rails['smtp_enable'] = true
# gitlab_rails['smtp_address'] = "smtp.maxwoods.net"
# gitlab_rails['smtp_port'] = 25
# gitlab_rails['smtp_user_name'] = "gitlab@maxwoods.net"
# gitlab_rails['smtp_password'] = "your password"
# gitlab_rails['smtp_domain'] = "smtp.maxwoods.net"
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = false
# gitlab_rails['smtp_tls'] = false
# 如果是阿里云服务器禁用了25端口，则改用下面配置：
# gitlab_rails['smtp_port'] = 465
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['smtp_tls'] = true
# 更新配置：
# gitlab-ctl reconfigure
# 重启：
# gitlab-ctl restart
# 运行控制台：
# gitlab-rails console
# 输入下面指令，看看是否是smtp发送邮件：
# ActionMailer::Base.delivery_method
# 查看邮件发送配置：
# ActionMailer::Base.smtp_settings
# 测试邮件发送：
# Notify.test_email('someemail@qq.com', 'gitlab test mail', 'This is from gitlab mail test!').deliver_now
# 关于external_url设定端口和容器映射端口不一致的问题，假设配置如下：
# external_url 'http://35.220.133.116:30080'
# 容器映射为80到宿主机30080，这时修改启动容器是无法访问的，最简单的方法是删除原容器，保留映射卷的内容，重新创建容器，同时修改端口号映射：
# docker run -d \
#     --name gitlab \
#     -p 30443:443 -p 30080:30080 -p 30022:22 \
#     --restart=always \
#     -v /home/docker/gitlab/config:/etc/gitlab \
#     -v /home/docker/gitlab/logs:/var/log/gitlab \
#     -v /home/docker/gitlab/data:/var/opt/gitlab \
#     gitlab/gitlab-ce
